package com.levy.contronller.javase.designModel.proxy;

import java.lang.reflect.*;
import java.lang.reflect.Proxy;

/**
 * 针对不改变代码的情况下  可以添加公用的功能代码
 * Created by levy on 2018/7/18.
 */
public class MainClass {

    public static void main(String[] args) {

        ProxyHander ph = new ProxyHander();
        RealSubject rs  =new RealSubject();
        ph.setRealSubject(rs);
        Subject o = (Subject) Proxy.newProxyInstance(RealSubject.class.getClassLoader(),
                rs.getClass().getInterfaces(), ph);
        o.sellBook();
    }
}
